﻿using DotNetty.Transport.Channels;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FirstDemoClient
{
    /// <summary>
    /// 客户端自定义处理类
    /// </summary>
    public class DemoClientHandler : SimpleChannelInboundHandler<string>
    {
        /// <summary>
        /// 接收服务端的消息
        /// </summary>
        /// <param name="ctx"></param>
        /// <param name="msg"></param>
        protected override void ChannelRead0(IChannelHandlerContext ctx, string msg)
        {
            Console.WriteLine("来自服务端的消息:" + msg + "\r\n");
        }

        /// <summary>
        /// 连接上服务器的时候触发
        /// </summary>
        /// <param name="context"></param>
        public override void ChannelActive(IChannelHandlerContext context)
        {
            Console.WriteLine("ChannelActive");
            Console.WriteLine("客户端连接上了服务器!");
        }
    }
}
